package cn.cvs.service.storageRecord;

import cn.cvs.dao.StorageRecordMapper;

import cn.cvs.pojo.StorageRecord;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * 供货单业务层实现
 */
@Service("storageRecordService")
public class StorageRecordServiceImpl implements StorageRecordService {
	@Resource
	private StorageRecordMapper storageRecordMapper;

	@Override
	public List<StorageRecord> getList(String supName, Integer supplierId, Integer payStatus
			, Integer pageIndex, Integer pageSize)throws Exception {
		//int pageBegin = (pageIndex-1)*pageSize;
		return storageRecordMapper.getList(supName, supplierId, payStatus, pageIndex, pageSize);
	}

	@Override
	public int getCount(String supName, Integer supplierId,
			Integer payStatus) throws Exception {
		// TODO Auto-generated method stub
		return storageRecordMapper.getCount(supName, supplierId, payStatus);
	}

	@Override
	public boolean add(StorageRecord storageRecord) throws Exception {
		boolean flag = false;
		storageRecord.setCreatedTime(new Date());
		//if(storageRecordMapper.add(storageRecord) > 0)
			flag = true;
		return storageRecordMapper.add(storageRecord);
	}

	@Override
	public StorageRecord getById(Integer id) throws Exception {
		return storageRecordMapper.getById(id);
	}

	@Override
	public boolean update(StorageRecord storageRecord) throws Exception {
		boolean flag = false;
		storageRecord.setUpdatedTime(new Date());
		//if(storageRecordMapper.update(storageRecord) > 0)
			flag = true;
		return storageRecordMapper.update(storageRecord);
	}

	@Override
	public boolean deleteById(Integer delId) throws Exception {
		boolean flag = false;
		//if(storageRecordMapper.deleteById(delId) > 0)
			flag = true;
		return storageRecordMapper.deleteById(delId);
	}

}
